<?php
namespace Mobile\Controller;
class CompanyController extends PublicController{
	function list(){
		$this->tit();
		if(!isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
			$this->seach();
		}else{
		// $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
   //      preg_match("#http://(.*?)\.#i ",$url,$match);
   //      if($match[1]==www){
   //          $Ip = new \Org\Net\IpLocation('qqwry.dat');
   //          $ip = get_client_ip();
   //          $arr = $Ip->getlocation($ip);
   //          $country = $arr["country"];
   //          $city = iconv("GB2312","UTF-8",$country);
   //          $arr = explode(省,$city);
   //          $data=$arr["1"];
   //      }else{
   //          $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
   //          preg_match("#http://(.*?)\.#i ",$url,$match);
   //          $cityOb = M("City");
   //          $arr = $cityOb->where("pinyin='$match[1]'")->find();
   //          $data = $arr['name'];
   //      }
		$comOb = M("Gongsi");
		$num=$comOb->where("isshow=1 and s_city='$data'")->count();
// 		3、规定每页显示的条数
		$pageSize=5;
// 		4、实例化分页类
		$pageOb=new \Think\Page($num,$pageSize);
// 		5、获取开始位置值
		$start=$pageOb->firstRow;
// 		6、获取分页结果
		$pageStr=$pageOb->show();
		// $area = $_GET["s_county"];
		$arr = $comOb->limit(5)->order('id desc')->select();
		$this->assign('arr',$arr);
		}
		$this->display();
	}
	function deatil(){
		$this->tit();
		$comOb = M("Gongsi");
		$id=$_GET["id"];
		$arr = $comOb->where("id=$id")->find();
		$this->assign('arr',$arr);
		$this->display();
	}
	function seach(){
		$keyword = $_POST['keyword'];
		$comOb = M("Gongsi");
		$map['cname']=array('like',"%$keyword%");
		$sarr = $comOb->where($map)->select();
		echo json_encode($sarr);
	}
}